package peter.study.spring.videocource.genericity;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import peter.study.spring.videocource.genericity.beans.Role;
import peter.study.spring.videocource.genericity.beans.RoleServlet;
import peter.study.spring.videocource.genericity.beans.User;
import peter.study.spring.videocource.genericity.beans.UserServlet;

public class Main {

	public static void main(String[] args) {
		/**
		 * 依赖泛型的注入，一旦注入了Servlet的子类，就根据泛型关系自动注入对应的Factory的子类。
		 * 如UserServlet与UserFactory。
		 */
		ConfigurableApplicationContext ctxt = new ClassPathXmlApplicationContext("peter/study/spring/videocource/genericity/genericity.xml");
		UserServlet userServlet = (UserServlet) ctxt.getBean("userServlet");
		userServlet.service(new User());

		RoleServlet roleServlet = (RoleServlet) ctxt.getBean("roleServlet");
		roleServlet.service(new Role());
		ctxt.close();
	}

}
